package com.ihome.android.academy;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;

public class SelfbootReceiver extends BroadcastReceiver {
	private final String	TAG			= SelfbootReceiver.class.getSimpleName();
	private final String	PrePkgName	= "com.ihome.android.academy";
	
	@Override
	public void onReceive(Context context, Intent intent) {
		String mAction = intent.getAction();
		String pkgName = intent.getDataString();
		Log.d(TAG, "check if to start appstore");
		if (mAction.equals(Intent.ACTION_PACKAGE_REPLACED) && pkgName.trim().contains(PrePkgName)) {
			Log.d(TAG,"to start appstore");
			Intent mIntent = new Intent(context, InitialActivity.class);
			mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(mIntent);
		}
	}
}
